﻿using BigEgg.Framework.Foundation;
using BigEgg.Framework.UnitTesting;
using FMStudio.Domain.Properties;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Globalization;

namespace FMStudio.Domain.SQLite.Test
{
    [TestClass]
    public class CityTest
    {
        [TestMethod]
        public void GeneralCityTest()
        {
            City city = new City();

            Assert.IsNotNull(city.ID);
            Assert.AreEqual("", city.Name);

            city.Name = "Shanghai";

            Assert.AreEqual("", city.Validate());
        }

        [TestMethod]
        public void CityNameValidationTest()
        {
            City city = new City();

            Assert.AreEqual(string.Empty, city.Name);
            Assert.AreEqual(Resources.CityNameMandatory, city.Validate("Name"));

            city.Name = TestHelper.CreateString('A', 99);
            Assert.AreEqual("", city.Validate("Name"));
            city.Name = TestHelper.CreateString('A', 100);
            Assert.AreEqual("", city.Validate("Name"));
            city.Name = TestHelper.CreateString('A', 101);
            Assert.AreEqual(
                string.Format(CultureInfo.CurrentCulture, Resources.CityNameMaxLength, "Name", 100)
                , city.Validate("Name"));
        }
    }
}
